package xdu.lz.stage1_basic.chapter2_api.a_group;

import java.util.Arrays;

public class Code01_ThreadGroup {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },"xxx");
        System.out.println("xxx线程的组:"+thread.getThreadGroup().getName());
        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        System.out.println("main线程的组:"+threadGroup.getName());
        System.out.println("当前线程组的线程数:"+threadGroup.activeCount());
        Thread[] threads = new Thread[threadGroup.activeCount()];
        System.out.println(threads.length);
        threadGroup.enumerate(threads);
        Arrays.asList(thread).forEach(System.out::println);
    }
}
